<?php

class RequestedElementsMenu extends TTemplateControl
{
	public function onLoad($params)
	{
		parent::onLoad($params);

		if(!$this->Page->IsPostback)
		{
			
			$element_manager = $this->Application->Modules['conference_elements'];
			$conference_element_list = array();
			$conference_element_list[] = array(	'id' => 0,
												'name' => Prado::localize('All'));
		
			foreach($element_manager->getConferenceElementsListByIsSession() as $conference_element)
				$conference_element_list[] = array(	'id' => $conference_element->getId(),
													'name' => $conference_element->getName());
											
			$this->session_list->DataValueField = 'id';
			$this->session_list->DataTextField  = 'name';
			$this->session_list->DataSource = $conference_element_list;
			$this->session_list->dataBind();
		
			$session_id = $this->Application->Request['session_id'];
			if(!$session_id)
				$session_id = 0;
			$this->session_list->setSelectedValue($session_id);
		}
	}
	
	public function setSessionId($session_id)
	{
		$this->setViewState('session_id', $session_id);
	}
	
	public function getSessionId()
	{
		return $this->getViewState('session_id', null);
	}
	
	public function setStatus($status)
	{
		$this->setViewState('status', $status);
	}
	
	public function getStatus()
	{
		return $this->getViewState('status', null);
	}
	
	public function getParamsArray($status = null)
	{
		$params = array();
		if($status)
			$params['status'] = $status;
		if($this->getSessionId())
			$params['session_id'] = $this->getSessionId();
		return $params;
	}
	
	public function selectedSessionButtonClicked($sender, $params)
	{
		$session_id = $this->session_list->getSelectedValue();
		
		$params = array();
		if($this->getStatus())
			$params['status'] = $this->getStatus();
		if($session_id)
			$params['session_id'] = $session_id;

		$this->Response->redirect(
			$this->Service->constructUrl('committee.requested_elements.All', $params)
		);
	}
}

?>